package com.leet.code.simple_array;

/**
 * @description:    1413.逐步求和得到正数的最小值
 * @author: WYG
 * @time: 2021/1/4 9:18
 */

public class MinStartValue {

    public int minStartValue(int[] nums) {
        int min = 100;
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
            if (sum < min) {
                min = sum;
            }
        }
        return 1 - min > 0 ? (1 - min) : 1;
    }

}
